package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysLogistics;
import com.ruoyi.system.service.ISysLogisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/system/logistics")
public class SysLogisticsController extends BaseController
{
    @Autowired
    private ISysLogisticsService sysLogisticsService;

    /**
     * 查询物流信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysLogistics sysLogistics)
    {
        startPage();
        List<SysLogistics> list = sysLogisticsService.selectSysLogisticsList(sysLogistics);
        return getDataTable(list);
    }

    /**
     * 导出物流信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:export')")
    @Log(title = "物流信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysLogistics sysLogistics)
    {
        List<SysLogistics> list = sysLogisticsService.selectSysLogisticsList(sysLogistics);
        ExcelUtil<SysLogistics> util = new ExcelUtil<SysLogistics>(SysLogistics.class);
        util.exportExcel(response, list, "物流信息数据");
    }

    /**
     * 获取物流信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:query')")
    @GetMapping(value = "/{logisticsId}")
    public AjaxResult getInfo(@PathVariable("logisticsId") Long logisticsId)
    {
        return success(sysLogisticsService.selectSysLogisticsByLogisticsId(logisticsId));
    }

    /**
     * 新增物流信息
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:add')")
    @Log(title = "物流信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysLogistics sysLogistics)
    {
        return toAjax(sysLogisticsService.insertSysLogistics(sysLogistics));
    }

    /**
     * 修改物流信息
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:edit')")
    @Log(title = "物流信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysLogistics sysLogistics)
    {
        return toAjax(sysLogisticsService.updateSysLogistics(sysLogistics));
    }

    /**
     * 删除物流信息
     */
    @PreAuthorize("@ss.hasPermi('system:logistics:remove')")
    @Log(title = "物流信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logisticsIds}")
    public AjaxResult remove(@PathVariable Long[] logisticsIds)
    {
        return toAjax(sysLogisticsService.deleteSysLogisticsByLogisticsIds(logisticsIds));
    }
}
